package com.xncoding.valid.Aware;
import org.springframework.beans.BeansException;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Component
public class MyEnvironmentAware implements EnvironmentAware {

    private Environment environment;

    @Override
    public void setEnvironment(Environment environment) throws BeansException {
        this.environment = environment;
    }

    public void doSomething(String peoperty) {
        // 使用environment读取配置属性
        String property = environment.getProperty(peoperty);
    }
}